load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_python//python:defs.bzl", "py_library")

cc_library(
    name = "fasttext",
    srcs = glob(
        ["src/**/*.cc"],
        exclude = ["src/main.cc"],
    ),
    hdrs = glob(
        ["src/**/*.h"],
        exclude = ["src/aligned.h"],
    ),
    copts = ["-std=c++17"],
    features = ["parse_headers"],
    include_prefix = "fasttext",
    includes = ["src"],
    strip_include_prefix = "src",
    textual_hdrs = ["src/aligned.h"],
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "cli",
    srcs = ["src/main.cc"],
    copts = ["-std=c++17"],
    linkopts = ["-pthread"],
    visibility = ["//visibility:public"],
    deps = [":fasttext"],
)

pybind_extension(
    name = "fasttext_pybind",
    srcs = ["python/fasttext_module/fasttext/pybind/fasttext_pybind.cc"],
    copts = ["-std=c++17"],
    visibility = ["//visibility:public"],
    deps = [":fasttext"],
)

py_library(
    name = "pybind",
    srcs = [
        "python/fasttext_module/fasttext/FastText.py",
        "python/fasttext_module/fasttext/__init__.py",
    ],
    data = [":fasttext_pybind"],
    imports = [
        ".",
        "python/fasttext_module",
    ],
    visibility = ["//visibility:public"],
)
